package com.flyco.modules.task.xml;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@XStreamAlias("IT_RESULT")
@Data
public class SapDistributorStatementRespXML {
    @XStreamImplicit(itemFieldName = "item")
    private List<DistributorStatementItem> itemList = new ArrayList<>();

    public DistributorStatementItem getItemByType(String type) {
        return itemList.stream().filter(q -> Objects.equals(q.getZCTYP(), type)).findFirst().orElse(null);
    }

    @Data
    @XStreamAlias("item")
    public class DistributorStatementItem {

        @XStreamAlias("ZINDEX")
        private String ZINDEX;

        @XStreamAlias("KUNNR")
        private String KUNNR;

        @XStreamAlias("BUKRS")
        private String BUKRS;

        @XStreamAlias("GJAHR")
        private String GJAHR;

        @XStreamAlias("ZMONTH")
        private String ZMONTH;

        @XStreamAlias("OFFICTXT")
        private String OFFICTXT;

        @XStreamAlias("ZCTYP")
        private String ZCTYP;

        /**
         *
         */
        @XStreamAlias("BUDAT")
        private String BUDAT;

        /**
         *
         */
        @XStreamAlias("SGTXT")
        private String SGTXT;

        /**
         * 余额
         */
        @XStreamAlias("ZJINE1")
        private BigDecimal ZJINE1;

        /**
         * 销售额
         */
        @XStreamAlias("ZJINE2S")
        private BigDecimal ZJINE2S;

        /**
         * 收款
         */
        @XStreamAlias("ZJINE2H")
        private BigDecimal ZJINE2H;
    }
}

